package Controller;
import java.util.Date;

import javax.swing.JFrame;
import javax.swing.JPanel;

import Entity.ComplaintReport;
import Entity.DisabledReport;
import Entity.MalfuncExceptReport;
import Entity.OrderReport;
import Entity.PerformanceReport;
import Entity.PeriodicReport;
import Entity.Request;
import GUI.ApproveRequestForChangingRatesGUI;
import GUI.ChooseDateMalfunc;
import GUI.ChooseDatePerformance;
import GUI.ChooseDatePeriodic;
import GUI.CompanyManagerWin;
import GUI.DisableSaveActivatePlSpotGui;
import GUI.FrameSystem;
import GUI.StatusPictureWin;
import GUI.ViewComplaintStatusReport;
import GUI.ViewDisabledReport;
import GUI.ViewMalfunctionExceptionsReport;
import GUI.ViewOrders;
import GUI.ViewOrdersReport;
import GUI.ViewPerformanceReport;
import GUI.ViewPeriodicReport;
import GUI.ViewReports;

/**
 * this is the controller for the company manager. it will run the GUI windows for his options:
 * approve change rates requests, reprts and view orders and workers.
 * @author Moran Abilea and Shaher Shelly
 *
 */
public class CompanyManagerController {
	/**
	 * is a static function that will get us from the DB the requests array.
	 * @return the array of requests.
	 */
	public static Request[] getRequestsforChangingRates()
	{
		Request[] myr=new Request[6];
		myr=DBcontroller.viewRequestsSQL(); // we will call the SQL function.
		return myr;
	} 
	   
   public CompanyManagerController() {
		// TODO Auto-generated constructor stub
	}
	
   /**
    *  is the main that will run us the main GUI.
    */
	public static void MainGUI()
	{
		CompanyManagerWin w=new CompanyManagerWin();
		w.setVisible(true);
	}
	
	/**
	 * is the function for viewing the parking lot report. 
	 */
	public static void ViewParkingLotReport()
	{
		JFrame frame=FrameSystem.getFrame();
		ViewReports plwGui=new ViewReports(DBcontroller.getOrderReports(),DBcontroller.getComplaintReports(),DBcontroller.getDisabledReports());
		plwGui.setLastPanel((JPanel)frame.getContentPane());
		plwGui.setFrame(frame);
		frame.setContentPane(plwGui);
		frame.setVisible(true);
	}
	
	/**
	 * is the function for view the orders report.
	 *@param o= order report.
	 */
	/*public static void viewOrderReport(OrderReport o)
	{
		ViewOrdersReport vor=new ViewOrdersReport(o);
		vor.setVisible(true);
	}*/

	/**
	 * is the function for viewing the complaints report.
	 * @param c= the complaint report
	 */
	/*public static void viewComplaintReport(ComplaintReport c) 
	{
		ViewComplaintStatusReport n=new ViewComplaintStatusReport(c);
		n.setVisible(true);
	}*/
	/**
	 * is the function for viewing the disabled parking spots report.
	 * @param d= disabled report
	 */
	/*public static void viewDisabledReport(DisabledReport d) 
	{
		ViewDisabledReport r=new ViewDisabledReport(d);
		r.setVisible(true);
		
	}*/
	
	/**
	 * is the function for viewing the periodic reports.
	 * @param start= from the start date.
	 * @param end= to the end date.
	 */
	public static void viewPeriodicReport(Date start,Date end) 
	{
		PeriodicReport d=new PeriodicReport(start,end);
		ViewPeriodicReport r=new ViewPeriodicReport(d);
		r.setVisible(true);
	}
	
	/*public static void ChooseDateForPeriodic() {
		ChooseDatePeriodic n=new ChooseDatePeriodic();
		n.setVisible(true);
	}*/

	/*public static void ChooseDateForPerfomance() 
	{
		
		ChooseDatePerformance n=new ChooseDatePerformance();
		n.setVisible(true);
	}*/
	/**
	 * is the function for viewing the performance report.
	 * @param start= start date
	 * @param end= end date
	 */
	public static void viewPerformanceReport(Date start, Date end) 
	{
		PerformanceReport d=new PerformanceReport(start,end);
		ViewPerformanceReport r=new ViewPerformanceReport(d);
		r.setVisible(true);
	}
	
	/*public static void ChooseDateForMalfunc()
	{
		ChooseDateMalfunc n=new ChooseDateMalfunc();
		n.setVisible(true);
	}*/
	
	/**
	 * is the function for viewing the malfunctions report.
	 * @param start= start date
	 * @param end= end date
	 */
	public static void viewMalfuncReport(Date start, Date end) 
	{
		MalfuncExceptReport d=new MalfuncExceptReport(start,end);
		ViewMalfunctionExceptionsReport r=new ViewMalfunctionExceptionsReport(d);
		r.setVisible(true);
	}
	
	/**
	 * is the function for viewing the window for approving the changing rates requests.
	 */
	public static void viewApprove()
	{
		JFrame frame=FrameSystem.getFrame();
		ApproveRequestForChangingRatesGUI plwGui=new ApproveRequestForChangingRatesGUI();
		plwGui.setLastPanel((JPanel)frame.getContentPane());
		plwGui.setFrame(frame);
		frame.setContentPane(plwGui);
		frame.setVisible(true);
	}
	
	/**
	 * is the function for viewing the orders.
	 */
	public static void viewOrders()
	{
		JFrame frame=FrameSystem.getFrame();
		ViewOrders plwGui=new ViewOrders(DBcontroller.getOrders());
		plwGui.setLastPanel((JPanel)frame.getContentPane());
		plwGui.setFrame(frame);
		frame.setContentPane(plwGui);
		frame.setVisible(true);
	}
	/**
	 * is the function for viewing the workers.
	 */
	public static void viewWorkers()
	{
		JFrame frame=FrameSystem.getFrame();
		GUI.viewWorkers plwGui=new GUI.viewWorkers(DBcontroller.getWorkers());
		plwGui.setLastPanel((JPanel)frame.getContentPane());
		plwGui.setFrame(frame);
		frame.setContentPane(plwGui);
		frame.setVisible(true);
	}
	
	public static void viewStatus()
	{
		JFrame frame=FrameSystem.getFrame();
		StatusPictureWin plwGui=new StatusPictureWin();
		plwGui.setLastPanel((JPanel)frame.getContentPane());
		plwGui.setFrame(frame);
		frame.setContentPane(plwGui);
		frame.setVisible(true);
	}
}